<?php
include("../conn.php");
$arr=array();

if ($_REQUEST[userid] && $_REQUEST[couponid]) {

	$couponid = $_REQUEST[couponid];
	$couponids = explode(',', $couponid);

	$flag = true;
	if ($couponids[0] != 'false') {
		$query=mysql_query("UPDATE mycoupon set is_use=1 where userid='".$_REQUEST[userid]."' and id='".$couponids[0]."'");
		if (mysql_affected_rows()<=0) {
			$flag = false;
		}
	}
	if ($couponids[1] != 'false') {
		$query=mysql_query("UPDATE mycoupon set is_use=1 where userid='".$_REQUEST[userid]."' and id='".$couponids[1]."'");
		if (mysql_affected_rows()<=0) {
			$flag = false;
		}
	}

	// $delete_query=mysql_query("DELETE from mycoupon where userid='".$_REQUEST[userid]."' and couponid='".$_REQUEST[couponid]."'");
	if ($flag == true) {
		$arr[code]=100;
	}else{
		$arr[code]=300;
	}
}else{
	$arr[code]=200;
}
echo json_encode($arr);